package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-06-01
 * Time: 22:49
 */
public class BookList {
   //成员变量：书本 书本的有效个数
    private Book[] books = new Book[10];//实例化一个书本对象 与Book类串联起来
    private int usedSize;//有效的数据个数【实际放的书的个数】
    //书架：
    public BookList() {
        this.books[0] = new Book("三国演义", "罗贯中", 10, "小说");
        this.books[1] = new Book("西游记", "吴承恩", 20, "小说");
        this.books[2] = new Book("红楼梦", "曹雪芹", 50, "小说");
        //有效书本为3本
        this.usedSize = 3;
    }
    //添加图书需要知道usedSize与数组的的下标
    public Book getBooks(int pos) {
        return books[pos];
    }
    //注意：这里需要的是接口数组的下标
    public void setBooks(int pos, Book book) {
        this.books[pos] = book;
    }
    //这个是输出书架的容量
    public Book[] getBooks() {
        return books;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
}
